package com.ipet.order.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ipet.order.pojo.Order;
import com.ipet.order.pojo.OrderStatus;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select * from tb_order")
    @Results({
            @Result(id = true , property = "orderId" , column = "order_id"),
            @Result(property = "orderStatus" , column = "order_id" ,javaType = OrderStatus.class,one = @One(select = "com.ipet.order.mapper.OrderStatusMapper.findByOrderId")),
            @Result(property = "orderDetail",column = "order_id" , javaType = List.class,
            many = @Many(select = "com.ipet.order.mapper.OrderDetailMapper.findDetailsByOrderId"))
    })
    List<Order> findallOrder();
    @Select("select * from tb_order where order_id = #{orderId}")
    @Results({
            @Result(id = true , property = "orderId" , column = "order_id"),
            @Result(property = "orderStatus" , column = "order_id" ,javaType = OrderStatus.class,one = @One(select = "com.ipet.order.mapper.OrderStatusMapper.findByOrderId")),
            @Result(property = "orderDetail",column = "order_id" , javaType = List.class,
                    many = @Many(select = "com.ipet.order.mapper.OrderDetailMapper.findDetailsByOrderId"))
    })
    List<Order> findOrderById(Long orderId);
}
